from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response


def jwt_response_custom_handler(token, user=None, request=None):
    return {
        "token": token,
        "username": user.username,
        "user_id": user.id
    }



class Mypage(PageNumberPagination):
    page_size = 3
    page_query_param = "page"
    page_size_query_param = "pagesize"
    max_page_size = 10

    # TODO 此出事为了修改分页后返回的数据数据
    def get_paginated_response(self,data):
        return Response({
            "counts": self.page.paginator.count,
            "lists": data,
            "page": self.page.number,
            "pages": self.page.paginator.num_pages,
            "pagesize": self.page_size,
        })